package org.example.scenicspot.service;

import org.example.scenicspot.domain.ScenicSpot;
import org.example.scenicspot.domain.Staff;
import org.example.scenicspot.persistence.staffMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class staffService {
    @Autowired
    staffMapper staffMapper;
    public  List<Staff> showstaff(){
        return staffMapper.selectAll();
    }

    public  List<Staff> searchstaff(String keyword){
        return staffMapper.selectByName(keyword);
    }

    public  List<Staff> selectByScenicAreaID(int scenicAreaID){
        return staffMapper.selectByScenicAreaID(scenicAreaID);
    }

    public  void deletestaff(int id){
        staffMapper.deleteById(id);
    }

    public  void insertstaff(Staff staff){
        staffMapper.insert(staff.getId(),staff.getName(),staff.getRole(),staff.getContactInfo(),staff.getScenicAreaID());
    }

    public  void updatestaff(Staff staff){
        staffMapper.update(staff.getId(),staff.getName(),staff.getRole(),staff.getContactInfo(),staff.getScenicAreaID());
    }

}
